package com.iona.utils;

import com.iona.dao.DisciplineDAO;
import com.iona.dao.PartDisDAO;
import com.iona.dao.PurviewDAO;
import com.iona.dao.StudyWorkDAO;
import com.iona.domain.Abilities;
import com.iona.domain.Authors;
import com.iona.domain.Discipline;
import com.iona.domain.DisciplinePurview;
import com.iona.domain.EducationSupport;
import com.iona.domain.EstimationMeans;
import com.iona.domain.FormsOfControl;
import com.iona.domain.Knowleges;
import com.iona.domain.LevelsOfFormation;
import com.iona.domain.MethodsOfFormation;
import com.iona.domain.Ownership;
import com.iona.domain.PartDis;
import com.iona.domain.PartDisPurview;
import com.iona.domain.Purposes;
import com.iona.domain.Purview;
import com.iona.domain.Reviewers;
import com.iona.domain.Semester;
import com.iona.domain.StagesOfFormation;
import com.iona.domain.StudyWork;
import com.iona.domain.SupportOfPurview;
import com.iona.domain.Templates;
import com.iona.domain.TemplatesForPurview;
import com.iona.domain.TypeStudyWork;

public class CreatorUtil {
	public static Discipline createSubject(String name, String desc) {
		Discipline s = new Discipline();
		s.setName(name);
		s.setDescription(desc);
		return s;
	}

	public static Purview createPurview(String name, String desc) {
		Purview p = new Purview();
		p.setName(name);
		p.setDescription(desc);
		return p;
	}

	public static DisciplinePurview createDP(Integer disId, Integer purId) {
		DisciplinePurview dp = new DisciplinePurview();
		Discipline discipline = new DisciplineDAO().findById(disId);
		dp.setDiscipline(discipline);
		discipline.getPurviewList().add(dp);
		Purview purview = new PurviewDAO().findById(purId);
		purview.getDisciplineList().add(dp);
		dp.setPurview(purview);
		return dp;
	}

	public static TypeStudyWork createTypeOfStudyWork(String shortName,
			String fullName) {
		TypeStudyWork tsw = new TypeStudyWork();
		tsw.setShortname(shortName);
		tsw.setFullname(fullName);
		return tsw;
	}
	
	public static Semester createSemester(Integer number) {
		Semester s = new Semester();
		s.setNumber(number);
		return s;
	}
	
	public static EducationSupport createEducationSupport(String name) {
		EducationSupport es = new EducationSupport();
		es.setName(name);
		return es;
	}
	
	public static PartDis createPartDis(String name,
			String description, String semester, String control) {
		PartDis pd = new PartDis();
		pd.setName(name);
		pd.setDescription(description);
		pd.setSemester(semester);
		pd.setControl(control);
		return pd;
	}
	public static Templates createTemplates(String qualification,
			String formOfStudy, String author, String statement, 
			String dateOfStatement, String numberOfProtocol,
			String toKnow, String beAbleTo, String toOwn, 
			String dificultyInCreditUnits, String dificultyInHours,
			String educationTecnology, String controlOfMaking, 
			String stuffOfDiscipline) {
		Templates t = new Templates();
		t.setQualification(qualification);
		t.setFormOfStudy(formOfStudy);
		t.setAuthor(author);
		t.setStatement(statement);
		t.setDateOfStatement(dateOfStatement);
		t.setNumberOfProtocol(numberOfProtocol);
		t.setToKnow(toKnow);
		t.setBeAbleTo(beAbleTo);
		t.setToOwn(toOwn);
		t.setDificultyInCreditUnits(dificultyInCreditUnits);
		t.setDificultyInHours(dificultyInHours);
		t.setEducationTecnology(educationTecnology);
		t.setControlOfMaking(controlOfMaking);
		t.setStuffOfDiscipline(stuffOfDiscipline);
		return t;
	}
	public static StudyWork createStudyWork(String name,
			Integer countOfHours) {
		StudyWork sw = new StudyWork();
		sw.setName(name);
		sw.setCountOfHours(countOfHours);
		return sw;
	}
	public static com.iona.domain.PartDisStudyWork createPDSW(Integer pDisId, Integer stWId) {
		com.iona.domain.PartDisStudyWork pdsw = new com.iona.domain.PartDisStudyWork();
		PartDis partDis = new PartDisDAO().findById(pDisId);
		pdsw.setPartDis(partDis);
		partDis.getStudyworkList().add(pdsw);
		StudyWork studyWork = new StudyWorkDAO().findById(stWId);
		studyWork.getPartdisList().add(pdsw);
		pdsw.setStudyWork(studyWork);
		return pdsw;
	}
	public static PartDisPurview createPDP(Integer partDId, Integer purId) {
		PartDisPurview pdp = new PartDisPurview();
		PartDis partDiscipline = new PartDisDAO().findById(partDId);
		pdp.setPartDis(partDiscipline);
		partDiscipline.getPurviewList().add(pdp);
		Purview purview1 = new PurviewDAO().findById(purId);
		purview1.getPartdisList().add(pdp);
		pdp.setPurview(purview1);
		return pdp;
	}
	public static Abilities createAbilities(String name) {
		Abilities a = new Abilities();
		a.setName(name);
		return a;
	}
	public static Authors createAuthors(String name, String post,
			String rank) {
		Authors au = new Authors();
		au.setName(name);
		au.setPost(post);
		au.setRank(rank);
		return au;
	}
	public static EstimationMeans createEstimationMeans(String name) {
		EstimationMeans em = new EstimationMeans();
		em.setName(name);
		return em;
	}
	public static FormsOfControl createFormsOfControl(String name) {
		FormsOfControl foc = new FormsOfControl();
		foc.setName(name);
		return foc;
	}
	public static Knowleges createKnowleges(String name) {
		Knowleges k = new Knowleges();
		k.setName(name);
		return k;
	}
	public static LevelsOfFormation createLevelsOfFormation(String name,
			String description, String attributes) {
		LevelsOfFormation lof = new LevelsOfFormation();
		lof.setName(name);
		lof.setDescription(description);
		lof.setAttributes(attributes);
		return lof;
	}
	public static MethodsOfFormation createMethodsOfFormation(String name) {
		MethodsOfFormation mof = new MethodsOfFormation();
		mof.setName(name);
		return mof;
	}
	public static Ownership createOwnership(String name) {
		Ownership own = new Ownership();
		own.setName(name);
		return own;
	}
	public static Purposes createPurposes(String name) {
		Purposes p = new Purposes();
		p.setName(name);
		return p;
	}
	public static Reviewers createReviewers(String name, String post,
			String rank) {
		Reviewers r = new Reviewers();
		r.setName(name);
		r.setPost(post);
		r.setRank(rank);
		return r;
	}
	public static StagesOfFormation createStagesOfFormation(String name, String description,
			String duration) {
		StagesOfFormation sof = new StagesOfFormation();
		sof.setName(name);
		sof.setDescription(description);
		sof.setDuration(duration);
		return sof;
	}
	public static SupportOfPurview createSupportOfPurview(String name) {
		SupportOfPurview sop = new SupportOfPurview();
		sop.setName(name);
		return sop;
	}
	public static TemplatesForPurview createTemplatesForPurview(String typeOfPurview, 
			String name, String preparationDirection, String preparationProfile, 
			String qualification, String time, String importanceOfPurview, String theoreticalDificulty, 
			String practicalDificulty, String baseStructure, String conditionsOfFormation,
			String statement, String year, String numberOfProtocol) {
		TemplatesForPurview tfp = new TemplatesForPurview();
		tfp.setTypeOfPurview(typeOfPurview);
		tfp.setName(name);
		tfp.setPreparationDirection(preparationDirection);
		tfp.setPreparationProfile(preparationProfile);
		tfp.setQualification(qualification);
		tfp.setTime(time);
		tfp.setImportanceOfPurview(importanceOfPurview);
		tfp.setTheoreticalDificulty(theoreticalDificulty);
		tfp.setPracticalDificulty(practicalDificulty);
		tfp.setBaseStructure(baseStructure);
		tfp.setConditionsOfFormation(conditionsOfFormation);
		tfp.setStatement(statement);
		tfp.setYear(year);
		tfp.setNumberOfProtocol(numberOfProtocol);
		return tfp;
	}
}
